#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
    int minCostToSubstitude(string &s1, string &s2) {
        int n = s1.size(), m = s2.size();
        s1 = " " + s1;
        s2 = " " + s2;
        vector<vector<int>> dp(n + 1, vector<int>(m + 1));
        dp[0][0] = 0;
        for (int i = 1; i <= n; ++i) { dp[i][0] = i; }
        for (int j = 1; j <= m; ++j) { dp[0][j] = j; }
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= m; ++j) {
                dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]) + 1;
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (s1[i] != s2[j] ? 1 : 0));
            }
        }
        /*    s1->s2
         * dp[i][j] = dp[i][j-1] + 1 (s1 add)
         *          = dp[i-1][j] + 1 (s1 delete)
         *          = dp[i-1][j-1] + s1[i]!=s2[j]
         * */
        return dp[n][m];
    }
};
int main() {
    string s1, s2;
    cin >> s1 >> s2;
    cout << Solution().minCostToSubstitude(s1, s2) << endl;
}